﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Chinaer.Core.Helper
{
    public class ConfigHelper
    {
        /// <summary>
        /// 获取配置文件中数据库连接字符串
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static string GetConnectionString(string name)
        {
            try
            {
                return ConfigurationManager.ConnectionStrings[name].ConnectionString;
            }
            catch (Exception ex)
            {
                Chinaer.Core.Helper.ExceptonHelper.ThrowException(ex.Message);
            }
            return null;
        }

        public static string DefaultConnectionString
        {
            get
            {
                return GetConnectionString("ContextConn");
            }
        }

        public static string GetDefaultCustomerRoleID()
        {
            return GetAppSetting("defaultRoleID");
        }
        public static string GetDefaultShangJiaRoleID()
        {
            return GetAppSetting("defaultRoleID");
        }

        public static string GetDefaultAdministratorRoleID()
        {
            return GetAppSetting("defaultRoleID");
        }
        public static string GetDefaultEmployeeRoleID()
        {
            return GetAppSetting("defaultRoleID");
        }
        /// <summary>
        /// 获取配置文件中Appsetting中的值
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static string GetAppSetting(string name)
        {
            return ConfigurationManager.AppSettings[name];
        }
    }
}
